import { get } from 'lodash-es'
import { HMemberType } from '@/api/hmember-type/types'

export class HMemberCardTransaction {
  id?: string
  hotel_id?: string
  hmember_card_id?: string
  transaction_type?: string // INHOUSE, MEMBER, OUTSIDE
  hmember_type_id?: string
  hmember_type?: HMemberType
  room?: string
  guest_name?: string
  mobile?: string
  check_number?: string
  amount?: number
  locker?: string // 更衣柜
  checkin_time?: string | Date
  checkout_time?: string | Date
  consumption?: number
  balance?: number
  reference?: string // 备注
  created_id?: string
  updated_id?: string
  created_at?: string
  updated_at?: string;
  [key: string]: any

  constructor(data?: HMemberCardTransaction) {
    this.init(data)
  }
}

HMemberCardTransaction.prototype.init = function init(data?: HMemberCardTransaction) {
  this.id = get(data, 'id')
  this.hotel_id = get(data, 'hotel_id')
  this.hmember_card_id = get(data, 'hmember_card_id')
  this.transaction_type = get(data, 'transaction_type')
  this.hmember_type_id = get(data, 'hmember_type_id')
  this.hmember_type = get(data, 'hmember_type')
  this.room = get(data, 'room')
  this.guest_name = get(data, 'guest_name')
  this.mobile = get(data, 'mobile')
  this.check_number = get(data, 'check_number')
  this.amount = get(data, 'amount')
  this.locker = get(data, 'locker')
  this.checkin_time = get(data, 'checkin_time')
  this.checkout_time = get(data, 'checkout_time')
  this.consumption = get(data, 'consumption', 1)
  this.balance = get(data, 'balance')
  this.reference = get(data, 'reference')
  this.created_id = get(data, 'created_id')
  this.updated_id = get(data, 'updated_id')
  this.created_at = get(data, 'created_at')
  this.updated_at = get(data, 'updated_at')
}
